package day03;

public class WhileTest {
    public static void main(String[] args) {
        System.out.println(toBinary2(10));
    }
    public static String toBinary(int n){
        String binary = "";
        while(true){
            int s = n/2;
            int y = n%2;
            binary = y+binary;
            if(s==0)
                break;
            n=s;
        }
        return binary;
    }
    public static int toBinary2(int n){
        int result = 0;
        int count = 0;
        while(true){
            int s = n / 2;
            int y = n % 2;
            result = (int)(y*Math.pow(10,count++)+result);

            if(s==0)
                break;
            n = s;
        }
        return result;
    }
    public static int divisor(int m,int n){
        while(true){
            int y = m%n;
            if(y==0)
                break;
            m = n;
            n = y;
        }
        return n;
    }
}
